package com.ruibang.glass.produce.controller.ym.dbym;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruibang.glass.frequencycontrol.annotation.FrequencyControl;
import com.ruibang.glass.produce.domain.req.MachiningReq;
import com.ruibang.glass.produce.entity.DbMachining;
import com.ruibang.glass.produce.service.DbMachiningService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;


/**
 * @Author: songJinKang
 * @CreateTime: 2024-01-23  10:05
 * @Description: TODO:短边加工参数
 * @Version: 1.0
 */
@Api(tags = "短边研磨加工参数数据控制器")
@RestController
@RequestMapping("/api/glass/produce/dbym/machining")
public class DbMachiningController {

    @Autowired
    private DbMachiningService machiningService;

    @PostMapping("/pageQuery")
    @ApiOperation(value = "短边研磨加工参数", response = ResultBody.class)
    public ResultBody<IPage<DbMachining>> pageQuery(@RequestBody MachiningReq machiningReq) {
        return ResultBody.success(machiningService.pageQuery(machiningReq));
    }

    @PostMapping("/export")
    @ApiOperation(value = "数据导出", response = ResultBody.class)
    @FrequencyControl(time = 15, count = 2, target = FrequencyControl.Target.IP)
    @FrequencyControl(time = 30, count = 5, target = FrequencyControl.Target.IP)
    public void export(@RequestBody @Valid MachiningReq machiningReq, HttpServletResponse response) {
        machiningService.export(machiningReq, response);
    }

}
